#version 440


layout(location = 0) in vec2 qt_TexCoord;

layout(location = 0) out vec4 fragColor;

layout(std140, binding = 0) uniform buf {
    mat4 qt_Matrix;
    float qt_Opacity;
    float radius;
} ubuf;

layout(binding = 1) uniform sampler2D qt_Texture;

void main()
{
    vec4 tColor = texture(qt_Texture, qt_TexCoord);

    float dis = distance(qt_TexCoord, vec2(0.5, 0.5));
    float antialiseRadius = 0.01;
    float alpha = 1.0 - smoothstep(1.0 - ubuf.radius, 1.0 - ubuf.radius + antialiseRadius, dis);
    alpha *= ubuf.qt_Opacity;

    fragColor = vec4(tColor.rgb * alpha, alpha);
}
